Skip to content

Commit 05539fb

Browse files
authored
Create a GroupProfile for the Staff Content Team (#6587)
Create a GroupProfile for the Staff Content Team via data migration
1 parent 626a465 commit 05539fb

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
from django.db import migrations
2+
3+
4+
def create_staff_content_team_profile(apps, schema_editor):
5+
Group = apps.get_model('auth', 'Group')
6+
GroupProfile = apps.get_model('groups', 'GroupProfile')
7+
8+
try:
9+
group = Group.objects.get(name='Staff Content Team')
10+
except Group.DoesNotExist:
11+
raise Exception("Staff Content Team group must exist before running this migration")
12+
13+
if not GroupProfile.objects.filter(group=group).exists():
14+
GroupProfile.objects.create(
15+
group=group,
16+
information='Staff Content Team group for content management.',
17+
information_html='Staff Content Team group for content management.'
18+
)
19+
20+
21+
def remove_staff_content_team_profile(apps, schema_editor):
22+
Group = apps.get_model('auth', 'Group')
23+
GroupProfile = apps.get_model('groups', 'GroupProfile')
24+
25+
try:
26+
group = Group.objects.get(name='Staff Content Team')
27+
except Group.DoesNotExist:
28+
return
29+
30+
GroupProfile.objects.filter(group=group).delete()
31+
32+
33+
class Migration(migrations.Migration):
34+
dependencies = [
35+
('groups', '0003_auto_20250218_1157'),
36+
]
37+
38+
operations = [
39+
migrations.RunPython(
40+
create_staff_content_team_profile,
41+
remove_staff_content_team_profile
42+
),
43+
]

0 commit comments

Comments
 (0)